
<template>
	<view class="viewbox auto p-top20">
		
		<view class="row j-sa a-center fitTop">
			<block v-for="(item,index) in navlist" :key="index">
			   <view class="size28" 
			        :class="current == index?'white':'color_7e'"
					@click="changeNav(index)">{{item}}</view>
			</block>
		</view>
		<block v-for="(item,index) in noticeList" :key="index">
			<view class="row m-bot20" @click="detail(item)">
				<image :src="item.image" mode="aspectFill" class="imgList bor_radius_10"></image>
				
				<view class="rows ellipsis white size26 m-top10">{{item.title}}</view>
				<view class="white size26 m-top10"> {{item.desc}}</view>
			</view>
		</block>
		
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				noticeList:[],
				page:1,
				pagesize:20,
				getMore:true,
				
				navlist:['内容精选','活动玩法'],
				current:0,
			}
		},
		onLoad() {
			this.notice();
		},
		// noticeList
		methods: {
			changeNav(index){
				this.page = 1;
				this.current = index;
				this.getMore = true;
				this.current == 0?this.notice():this.newsList();
				
			},
			
			notice() {
				this.$http.get('index/noticeList',
				     {
					  page:this.page,
					  pagesize:this.pagesize,
					 }).then(res=> {
					if(res.code != 1) return;
					if(!res.data || !res.data.length || res.data.length < 10) this.getMore = false;
					this.page == 1?this.noticeList = res.data:this.noticeList = this.noticeList.concat(res.data);
					
				})
			},
			newsList() {
				console.log(this.current);
				this.$http.get('index/newsList',
				     {
					  page:this.page,
					  pagesize:this.pagesize,
					 }).then(res=> {
					if(res.code != 1) return;
					if(!res.data || !res.data.length || res.data.length < 10) this.getMore = false;
					this.page == 1?this.noticeList = res.data:this.noticeList = this.noticeList.concat(res.data);
					
				})
			},
			detail(con){
				this.toUrl(`/pages/index/txtdetail?con=${JSON.stringify(con)}`)
			},
		},
		onReachBottom() {
			if(!this.getMore) return;
			this.page ++;
			this.current == 0?this.notice():this.newsList();
		}
	}
</script>
<style>
	page {
		background-color: #1e201f;
	}
</style>
<style lang="scss" scoped>
	.imgList{
		width:100%;
		height: 300rpx;
	}
	.fitTop{
		width:100%;
		height: 100rpx;
	}
</style>
